package bigo.todolist.avocado;

import java.util.ArrayList;

import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.Drawable;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;
/**
 * Creates overlays on the map for each coordinate (task points)
 * @author Alex Irlik, Steve Fox, TiOluwa Olarewaju, Derek Miller
 * Big-Ovacado Task Force
 * Version 1.0
 *
 */
public class BigItemizedOverlay extends ItemizedOverlay<OverlayItem> {
	private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
	private Context mContext;

	/**
	 * 
	 * @param defaultMarker
	 * @param context
	 */
	public BigItemizedOverlay(Drawable defaultMarker, Context context) {
		  super(boundCenterBottom(defaultMarker));
		  mContext = context;
		}
	
	/**
	 * Add overlays and populate
	 * @param overlay
	 */
	public void addOverlay(OverlayItem overlay) {
	    mOverlays.add(overlay);
	    populate();
	}

	/**
	 * Create overlay
	 */
	protected OverlayItem createItem(int i) {
		return mOverlays.get(i);
	}

	/**
	 * Size of overlay
	 */
	public int size() {
		return mOverlays.size();
	}
	
	/**
	 * Actions when the point is tapped
	 */
	protected boolean onTap(int index) {
	  OverlayItem item = mOverlays.get(index);
	  AlertDialog.Builder dialog = new AlertDialog.Builder(mContext); //Display dialog box
	  dialog.setTitle(item.getTitle()); //Set the title
	  dialog.setMessage(item.getSnippet()); //Set the description
	  dialog.show(); //Show it
	  return true;
	}

}
